/*
 * @(#)RedrawableCallback.java
 *
 * @author <a href="gubarevs@apollo.lv">Denis Gubarev</a>
 */

package com.gshappcore.presentation.callback;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.InvocationException;
import com.gshappcore.model.Model;
import com.gshappcore.presentation.view.Redrawable;

public class RedrawableCallback implements AsyncCallback {

    private Redrawable redrawable;

    public RedrawableCallback(Redrawable redrawable) {
        this.redrawable = redrawable;
    }

    public void onSuccess(Object result) {
        redrawable.redraw((Model) result);
    }

    public void onFailure(Throwable throwable) {
        if (throwable instanceof InvocationException) {
            Window.alert("Connection to application is unavailable!");
        }
    }
}